﻿@{
    ViewBag.Title = "验收";
    Layout = "~/Views/Shared/_LayoutDualColumns.cshtml";
}
@using Ducu.GLB.Global
@using Global.Core.ExtensionMethod
@using Ducu.SRV.ViewModel.Task.Shared
@using Ducu.UI.Responsible.WebHelper
@model Ducu.SRV.ViewModel.Task.AcceptModel

@section PageHeader{
    <span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span><span class="after-glyphicon">@ViewBag.Title</span>
}

@{
    object planId = ViewContext.RouteData.Values["planId"];
    object taskId = Request.QueryString["taskId"];
    bool showNothingToDo = ViewBag.StillNeedAccept == null && taskId == null;
    bool onlyComment = ViewBag.OnlyComment == null ? false : ViewBag.OnlyComment;
}

@Html.Action("_ShowItem", "Plan", new { id = planId })

@if (showNothingToDo)
{
    <div>
        <p>没有任务可以验收了。</p>
    </div>
}
else
{
    <div class="well">
        <h3>
            @{string className = onlyComment ? DayIconHelper.GetClassName(Model.Current.Status) : "glyphicon glyphicon-check";}
            <span class="@className" aria-hidden="true" style="margin-right: 6px; position: relative; top: 4px;"></span>作业
        </h3>
        <hr />
        @if (!onlyComment)
        {
            <label>全部待验收：</label>
            @Html.Partial("_AllNeedAccept", Model.AllNeedAccepts, new ViewDataDictionary { { "Current", Model.Current.CompleteDate } })
            @Html.Action("_Proof", "Plan", new { id = planId })
            <p>
                <label>星期：</label>
                <span data-taskday-id="@Model.Current.Id" class="pull-right">
                    <a class="lead"><span class="glyphicon glyphicon-time"></span> 历史</a>
                </span>
                <table class="table table-bordered">
                    <tr>
                        <th>一</th>
                        <th>二</th>
                        <th>三</th>
                        <th>四</th>
                        <th>五</th>
                        <th>六</th>
                        <th>日</th>
                    </tr>
                    <tr>
                        @for (int i = 1; i <= 7; i++)
                        {
                            if (Model.Current.CompleteDate.GetChineseWeekDay() == i)
                            {
                                <td><span class="glyphicon glyphicon-check" data-taskday-id="@Model.Current.Id" title="@Model.Current.CompleteDate.ToChineseDate()"></span></td>
                            }
                            else
                            {
                                <td></td>
                            }
                        }
                    </tr>
                </table>
            </p>
        }
        else
        {
            <label>当前任务：</label>
            <span>@Model.Current.CompleteDate.ToChineseDate()</span>
            <span data-taskday-id="@Model.Current.Id" class="pull-right">
                <a class="lead"><span class="glyphicon glyphicon-time"></span> 历史</a>
            </span>
        }
        @if (!string.IsNullOrEmpty(Model.Current.Comment))
        {
            <p>
                <span class="lead">留言：</span>
                @Model.Current.Comment
            </p>
        }
    </div>
    @Html.Partial("Shared/_HistoryContainer")

    using (Html.BeginForm())
    {
        <div class="form-group">
            @if (!onlyComment)
            {
                <label>验收结果：</label>
                <label class="radio-inline">
                    @Html.RadioButtonFor(m => m.Status, Status.Accepted, new { @checked = "checked" }) 通过
                </label>
                <label class="radio-inline">
                    @Html.RadioButtonFor(m => m.Status, Status.Question) 疑问
                </label>
                <label class="radio-inline">
                    @Html.RadioButtonFor(m => m.Status, Status.Refused) 拒绝
                </label>
            }
            else
            {
                @Html.HiddenFor(m => m.Status, Status.Empty)
            }
        </div>
        <div class="form-group">
            <label>留言：</label>
            @Html.TextAreaFor(m => m.MyComment, new { @class = "form-control", rows = "3", placeholder = "给点鼓励，或者鞭策？如果拒绝验收，是一定要留言写理由的哟。" })
        </div>
        @Html.HiddenFor(m => m.Current.Id)
        @Html.Partial("_SubmitAndContinue", new ViewDataDictionary { { "Continue", ViewBag.StillNeedAccept > 1 } })
    }
}

@section RightPanel{
    @if (!onlyComment)
    {
        <li>
            仔细检查，小心这个狡猾的“苦修”打马虎眼哟。
        </li>
        <li>
            确实完成了？验收通过吧，还可以写两句话鼓励他一下的嘛。
        </li>
        <li>
            什么？根本没有完成！我说什么的来着吧。拒绝验收，一定的，给他/她一个大大的叉，哈哈哈！不过拒绝验收，是一定要留言写理由的哟。
        </li>
        <li>
            如果不太确定是否应该验收通过，需要再次确认的话，就选择“疑问”吧，也是一定要留言的哟。
        </li>
        <li>
            如果该目标有多个任务等待验收的话，系统会自动进入下一个任务的验收，直到该目标下所有任务验收完毕。
        </li>
    }
    else
    {
        <li>
            当前任务可能还未提交、已验收/拒绝等，所以状态不能再做修改，只能留言。
        </li>
        <li>
            留言不能为空，提交后会以“新消息”的方式发送给这个苦修。
        </li>
    }

}